#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 15;
const int S = 1100;
const int K = 310;
const int MOD = 998244353;

int h, w, n;
ll dp[K<<1][S];
int state[2][S][10];
string str[N];

int main() {
    cin >> h >> w >> n;
    for (int i = 0; i < h; i++) cin >> str[i];

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int s = 0; s < (1 << h); s++)
                if ((s >> i) & 1) state[0][s][str[i][j] - '0'] |= 1 << j;
            for (int s = 0; s < (1 << w); s++)
                if ((s >> j) & 1) state[1][s][str[i][j] - '0'] |= 1 << i;

        }
    }

    dp[0][(1<<h)-1] = 1;
    for (int i = 0; i < 2*n; i++) {
        int temp = (i&1) ? w : h;
        for (int s = 0; s < (1<<temp); s++) {
            for (int k = 0; k <= 9; k++) {
                int nxt = state[i&1][s][k];
                dp[i+1][nxt] = (dp[i+1][nxt]+dp[i][s]) % MOD;
            }
        }
    }

    ll res = 0;
    for (int i = 1; i < 1<<h; i++)
        res = (res + dp[n*2][i]) % MOD;
    cout << res << endl;

}